library(readr)
library(tidyverse)
Registered S3 method overwritten by 'dplyr':
method from
print.rowwise_df
[37m── [1mAttaching packages[22m ─────────────────────────────────────────────────── tidyverse 1.2.1 ──[39m
[37m[32m✔[37m [34mggplot2[37m 3.2.1 [32m✔[37m [34mpurrr [37m 0.3.3
[32m✔[37m [34mtibble [37m 2.1.3 [32m✔[37m [34mdplyr [37m 0.8.3
[32m✔[37m [34mtidyr [37m 1.0.0 [32m✔[37m [34mstringr[37m 1.4.0
[32m✔[37m [34mggplot2[37m 3.2.1 [32m✔[37m [34mforcats[37m 0.4.0[39m
[37m── [1mConflicts[22m ────────────────────────────────────────────────────── tidyverse_conflicts() ──
[31m✖[37m [34mdplyr[37m::[32mfilter()[37m masks [34mstats[37m::filter()
[31m✖[37m [34mdplyr[37m::[32mlag()[37m masks [34mstats[37m::lag()[39m
library(here)
here() starts at /Users/shimonmir/codeclan_work/codeclan_data_cleaning_project/task_4
library(janitor)
library(stringr)
library(readxl)
candy_1 <- read_xlsx(here("/raw_data/boing-boing-candy-2015.xlsx"))
candy_2 <- read_xlsx(here("/raw_data/boing-boing-candy-2016.xlsx"))
candy_3 <- read_xlsx(here("/raw_data/boing-boing-candy-2017.xlsx"))
New names:
* `` -> ...114
view(candy_1)
view(candy_2)
candy_1
NA
candy_1_clean_names <- clean_names(candy_1)
candy_1_clean_names
candy_1_less_columns <- candy_1_clean_names %>%
select(-contains("timestamp"))%>%
select(-contains("which_day")) %>%
select(-contains("please")) %>%
select(-contains("tears_of_sadness")) %>%
select(-contains("dress_that_went_viral")) %>%
select(-contains("fill_in_the_blank")) %>%
select(-contains("favourite_font")) %>%
select(-contains("squint_really_hard")) %>%
select(-contains("betty_or_veronica"))%>%
select(-contains("guess"))
candy_1_less_columns
candy_1_tidy <- candy_1_less_columns %>%
rename("going_out" = starts_with("are_you_going_actually")) %>%
## add year column
add_column("year" = 2015) %>%
## add column "you_gender", "country", as ....to match varaiables
add_column("your_gender" = "unknown", "country" = "unavailable") %>%
## how_old changed to age
rename("age" = "how_old_are_you") %>%
## try alternate
rename("100_grand_bar" = "x100_grand_bar")
candy_1_tidy
names(candy_1_tidy)
[1] "age"
[2] "going_out"
[3] "butterfinger"
[4] "100_grand_bar"
[5] "anonymous_brown_globs_that_come_in_black_and_orange_wrappers"
[6] "any_full_sized_candy_bar"
[7] "black_jacks"
[8] "bonkers"
[9] "bottle_caps"
[10] "box_o_raisins"
[11] "brach_products_not_including_candy_corn"
[12] "bubble_gum"
[13] "cadbury_creme_eggs"
[14] "candy_corn"
[15] "vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[16] "candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[17] "cash_or_other_forms_of_legal_tender"
[18] "chiclets"
[19] "caramellos"
[20] "snickers"
[21] "dark_chocolate_hershey"
[22] "dental_paraphenalia"
[23] "dots"
[24] "fuzzy_peaches"
[25] "generic_brand_acetaminophen"
[26] "glow_sticks"
[27] "broken_glow_stick"
[28] "goo_goo_clusters"
[29] "good_n_plenty"
[30] "gum_from_baseball_cards"
[31] "gummy_bears_straight_up"
[32] "creepy_religious_comics_chick_tracts"
[33] "healthy_fruit"
[34] "heath_bar"
[35] "hershey_s_kissables"
[36] "hershey_s_milk_chocolate"
[37] "hugs_actual_physical_hugs"
[38] "jolly_rancher_bad_flavor"
[39] "jolly_ranchers_good_flavor"
[40] "kale_smoothie"
[41] "kinder_happy_hippo"
[42] "kit_kat"
[43] "hard_candy"
[44] "lapel_pins"
[45] "lemon_heads"
[46] "licorice"
[47] "licorice_not_black"
[48] "lindt_truffle"
[49] "lollipops"
[50] "mars"
[51] "mary_janes"
[52] "maynards"
[53] "milk_duds"
[54] "laffy_taffy"
[55] "minibags_of_chips"
[56] "joy_joy_mit_iodine"
[57] "reggie_jackson_bar"
[58] "pixy_stix"
[59] "nerds"
[60] "nestle_crunch"
[61] "nown_laters"
[62] "pencils"
[63] "milky_way"
[64] "reese_s_peanut_butter_cups"
[65] "tolberone_something_or_other"
[66] "runts"
[67] "junior_mints"
[68] "senior_mints"
[69] "mint_kisses"
[70] "mint_juleps"
[71] "mint_leaves"
[72] "peanut_m_m_s"
[73] "regular_m_ms"
[74] "mint_m_ms"
[75] "ribbon_candy"
[76] "rolos"
[77] "skittles"
[78] "smarties_american"
[79] "smarties_commonwealth"
[80] "chick_o_sticks_we_don_t_know_what_that_is"
[81] "spotted_dick"
[82] "starburst"
[83] "swedish_fish"
[84] "sweetums"
[85] "those_odd_marshmallow_circus_peanut_things"
[86] "three_musketeers"
[87] "peterson_brand_sidewalk_chalk"
[88] "peanut_butter_bars"
[89] "peanut_butter_jars"
[90] "trail_mix"
[91] "twix"
[92] "vicodin"
[93] "white_bread"
[94] "whole_wheat_anything"
[95] "york_peppermint_patties"
[96] "sea_salt_flavored_stuff_probably_chocolate_since_this_is_the_it_flavor_of_the_year"
[97] "necco_wafers"
[98] "year"
[99] "your_gender"
[100] "country"
names(candy_1_tidy)
[1] "age"
[2] "going_out"
[3] "butterfinger"
[4] "100_grand_bar"
[5] "anonymous_brown_globs_that_come_in_black_and_orange_wrappers"
[6] "any_full_sized_candy_bar"
[7] "black_jacks"
[8] "bonkers"
[9] "bottle_caps"
[10] "box_o_raisins"
[11] "brach_products_not_including_candy_corn"
[12] "bubble_gum"
[13] "cadbury_creme_eggs"
[14] "candy_corn"
[15] "vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[16] "candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[17] "cash_or_other_forms_of_legal_tender"
[18] "chiclets"
[19] "caramellos"
[20] "snickers"
[21] "dark_chocolate_hershey"
[22] "dental_paraphenalia"
[23] "dots"
[24] "fuzzy_peaches"
[25] "generic_brand_acetaminophen"
[26] "glow_sticks"
[27] "broken_glow_stick"
[28] "goo_goo_clusters"
[29] "good_n_plenty"
[30] "gum_from_baseball_cards"
[31] "gummy_bears_straight_up"
[32] "creepy_religious_comics_chick_tracts"
[33] "healthy_fruit"
[34] "heath_bar"
[35] "hershey_s_kissables"
[36] "hershey_s_milk_chocolate"
[37] "hugs_actual_physical_hugs"
[38] "jolly_rancher_bad_flavor"
[39] "jolly_ranchers_good_flavor"
[40] "kale_smoothie"
[41] "kinder_happy_hippo"
[42] "kit_kat"
[43] "hard_candy"
[44] "lapel_pins"
[45] "lemon_heads"
[46] "licorice"
[47] "licorice_not_black"
[48] "lindt_truffle"
[49] "lollipops"
[50] "mars"
[51] "mary_janes"
[52] "maynards"
[53] "milk_duds"
[54] "laffy_taffy"
[55] "minibags_of_chips"
[56] "joy_joy_mit_iodine"
[57] "reggie_jackson_bar"
[58] "pixy_stix"
[59] "nerds"
[60] "nestle_crunch"
[61] "nown_laters"
[62] "pencils"
[63] "milky_way"
[64] "reese_s_peanut_butter_cups"
[65] "tolberone_something_or_other"
[66] "runts"
[67] "junior_mints"
[68] "senior_mints"
[69] "mint_kisses"
[70] "mint_juleps"
[71] "mint_leaves"
[72] "peanut_m_m_s"
[73] "regular_m_ms"
[74] "mint_m_ms"
[75] "ribbon_candy"
[76] "rolos"
[77] "skittles"
[78] "smarties_american"
[79] "smarties_commonwealth"
[80] "chick_o_sticks_we_don_t_know_what_that_is"
[81] "spotted_dick"
[82] "starburst"
[83] "swedish_fish"
[84] "sweetums"
[85] "those_odd_marshmallow_circus_peanut_things"
[86] "three_musketeers"
[87] "peterson_brand_sidewalk_chalk"
[88] "peanut_butter_bars"
[89] "peanut_butter_jars"
[90] "trail_mix"
[91] "twix"
[92] "vicodin"
[93] "white_bread"
[94] "whole_wheat_anything"
[95] "york_peppermint_patties"
[96] "sea_salt_flavored_stuff_probably_chocolate_since_this_is_the_it_flavor_of_the_year"
[97] "necco_wafers"
[98] "year"
[99] "your_gender"
[100] "country"
## time to pivot
## if source data changes, check col numbers match candy types before pivot
candy_1_long <- candy_1_tidy %>%
pivot_longer(cols = 3:97, names_to = "candy_type", values_to = "response")
candy_1_long
NA
NA
###CANDY_2###
candy_2
NA
##janitor: clean_names
candy_2_clean_names <- clean_names(candy_2)
names(candy_2_clean_names)
[1] "timestamp"
[2] "are_you_going_actually_going_trick_or_treating_yourself"
[3] "your_gender"
[4] "how_old_are_you"
[5] "which_country_do_you_live_in"
[6] "which_state_province_county_do_you_live_in"
[7] "x100_grand_bar"
[8] "anonymous_brown_globs_that_come_in_black_and_orange_wrappers"
[9] "any_full_sized_candy_bar"
[10] "black_jacks"
[11] "bonkers_the_candy"
[12] "bonkers_the_board_game"
[13] "bottle_caps"
[14] "boxo_raisins"
[15] "broken_glow_stick"
[16] "butterfinger"
[17] "cadbury_creme_eggs"
[18] "candy_corn"
[19] "candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[20] "caramellos"
[21] "cash_or_other_forms_of_legal_tender"
[22] "chardonnay"
[23] "chick_o_sticks_we_don_t_know_what_that_is"
[24] "chiclets"
[25] "coffee_crisp"
[26] "creepy_religious_comics_chick_tracts"
[27] "dental_paraphenalia"
[28] "dots"
[29] "dove_bars"
[30] "fuzzy_peaches"
[31] "generic_brand_acetaminophen"
[32] "glow_sticks"
[33] "goo_goo_clusters"
[34] "good_n_plenty"
[35] "gum_from_baseball_cards"
[36] "gummy_bears_straight_up"
[37] "hard_candy"
[38] "healthy_fruit"
[39] "heath_bar"
[40] "hersheys_dark_chocolate"
[41] "hershey_s_milk_chocolate"
[42] "hersheys_kisses"
[43] "hugs_actual_physical_hugs"
[44] "jolly_rancher_bad_flavor"
[45] "jolly_ranchers_good_flavor"
[46] "joy_joy_mit_iodine"
[47] "junior_mints"
[48] "senior_mints"
[49] "kale_smoothie"
[50] "kinder_happy_hippo"
[51] "kit_kat"
[52] "laffy_taffy"
[53] "lemon_heads"
[54] "licorice_not_black"
[55] "licorice_yes_black"
[56] "lindt_truffle"
[57] "lollipops"
[58] "mars"
[59] "mary_janes"
[60] "maynards"
[61] "mike_and_ike"
[62] "milk_duds"
[63] "milky_way"
[64] "regular_m_ms"
[65] "peanut_m_m_s"
[66] "blue_m_ms"
[67] "red_m_ms"
[68] "third_party_m_ms"
[69] "minibags_of_chips"
[70] "mint_kisses"
[71] "mint_juleps"
[72] "mr_goodbar"
[73] "necco_wafers"
[74] "nerds"
[75] "nestle_crunch"
[76] "nown_laters"
[77] "peeps"
[78] "pencils"
[79] "person_of_interest_season_3_dvd_box_set_not_including_disc_4_with_hilarious_outtakes"
[80] "pixy_stix"
[81] "reese_s_peanut_butter_cups"
[82] "reeses_pieces"
[83] "reggie_jackson_bar"
[84] "rolos"
[85] "skittles"
[86] "smarties_american"
[87] "smarties_commonwealth"
[88] "snickers"
[89] "sourpatch_kids_i_e_abominations_of_nature"
[90] "spotted_dick"
[91] "starburst"
[92] "sweet_tarts"
[93] "swedish_fish"
[94] "sweetums_a_friend_to_diabetes"
[95] "tic_tacs"
[96] "those_odd_marshmallow_circus_peanut_things"
[97] "three_musketeers"
[98] "tolberone_something_or_other"
[99] "trail_mix"
[100] "twix"
[101] "vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[102] "vicodin"
[103] "whatchamacallit_bars"
[104] "white_bread"
[105] "whole_wheat_anything"
[106] "york_peppermint_patties"
[107] "please_list_any_items_not_included_above_that_give_you_joy"
[108] "please_list_any_items_not_included_above_that_give_you_despair"
[109] "please_leave_any_witty_snarky_or_thoughtful_remarks_or_comments_regarding_your_choices"
[110] "guess_the_number_of_mints_in_my_hand"
[111] "betty_or_veronica"
[112] "that_dress_that_went_viral_a_few_years_back_when_i_first_saw_it_it_was"
[113] "what_is_your_favourite_font"
[114] "please_estimate_the_degree_s_of_separation_you_have_from_the_following_celebrities_jk_rowling"
[115] "please_estimate_the_degree_s_of_separation_you_have_from_the_following_celebrities_jj_abrams"
[116] "please_estimate_the_degree_s_of_separation_you_have_from_the_following_celebrities_beyonce"
[117] "please_estimate_the_degree_s_of_separation_you_have_from_the_following_celebrities_bieber"
[118] "please_estimate_the_degree_s_of_separation_you_have_from_the_following_celebrities_kevin_bacon"
[119] "please_estimate_the_degree_s_of_separation_you_have_from_the_following_celebrities_francis_bacon_1561_1626"
[120] "which_day_do_you_prefer_friday_or_sunday"
[121] "do_you_eat_apples_the_correct_way_east_to_west_side_to_side_or_do_you_eat_them_like_a_freak_of_nature_south_to_north_bottom_to_top"
[122] "when_you_see_the_above_image_of_the_4_different_websites_which_one_would_you_most_likely_check_out_please_be_honest"
[123] "york_peppermint_patties_ignore"
candy_2_less_columns <- candy_2_clean_names %>%
select(-contains("timestamp"))%>%
select(-contains("which_state_province_county_do_you_live_in")) %>%
select(-contains("which_day")) %>%
select(-contains("please")) %>%
select(-contains("tears_of_sadness")) %>%
select(-contains("dress_that_went_viral")) %>%
select(-contains("fill_in_the_blank")) %>%
select(-contains("favourite_font")) %>%
select(-contains("squint_really_hard")) %>%
select(-contains("do_you_eat_apples")) %>%
select(-contains("season_3_dvd")) %>%
select(-contains("different_websites")) %>%
select(-contains("patties_ignore")) %>%
select(-contains("betty_or_veronica"))%>%
select(-contains("guess"))
candy_2_less_columns
names(candy_2_less_columns)
[1] "are_you_going_actually_going_trick_or_treating_yourself"
[2] "your_gender"
[3] "how_old_are_you"
[4] "which_country_do_you_live_in"
[5] "x100_grand_bar"
[6] "anonymous_brown_globs_that_come_in_black_and_orange_wrappers"
[7] "any_full_sized_candy_bar"
[8] "black_jacks"
[9] "bonkers_the_candy"
[10] "bonkers_the_board_game"
[11] "bottle_caps"
[12] "boxo_raisins"
[13] "broken_glow_stick"
[14] "butterfinger"
[15] "cadbury_creme_eggs"
[16] "candy_corn"
[17] "candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[18] "caramellos"
[19] "cash_or_other_forms_of_legal_tender"
[20] "chardonnay"
[21] "chick_o_sticks_we_don_t_know_what_that_is"
[22] "chiclets"
[23] "coffee_crisp"
[24] "creepy_religious_comics_chick_tracts"
[25] "dental_paraphenalia"
[26] "dots"
[27] "dove_bars"
[28] "fuzzy_peaches"
[29] "generic_brand_acetaminophen"
[30] "glow_sticks"
[31] "goo_goo_clusters"
[32] "good_n_plenty"
[33] "gum_from_baseball_cards"
[34] "gummy_bears_straight_up"
[35] "hard_candy"
[36] "healthy_fruit"
[37] "heath_bar"
[38] "hersheys_dark_chocolate"
[39] "hershey_s_milk_chocolate"
[40] "hersheys_kisses"
[41] "hugs_actual_physical_hugs"
[42] "jolly_rancher_bad_flavor"
[43] "jolly_ranchers_good_flavor"
[44] "joy_joy_mit_iodine"
[45] "junior_mints"
[46] "senior_mints"
[47] "kale_smoothie"
[48] "kinder_happy_hippo"
[49] "kit_kat"
[50] "laffy_taffy"
[51] "lemon_heads"
[52] "licorice_not_black"
[53] "licorice_yes_black"
[54] "lindt_truffle"
[55] "lollipops"
[56] "mars"
[57] "mary_janes"
[58] "maynards"
[59] "mike_and_ike"
[60] "milk_duds"
[61] "milky_way"
[62] "regular_m_ms"
[63] "peanut_m_m_s"
[64] "blue_m_ms"
[65] "red_m_ms"
[66] "third_party_m_ms"
[67] "minibags_of_chips"
[68] "mint_kisses"
[69] "mint_juleps"
[70] "mr_goodbar"
[71] "necco_wafers"
[72] "nerds"
[73] "nestle_crunch"
[74] "nown_laters"
[75] "peeps"
[76] "pencils"
[77] "pixy_stix"
[78] "reese_s_peanut_butter_cups"
[79] "reeses_pieces"
[80] "reggie_jackson_bar"
[81] "rolos"
[82] "skittles"
[83] "smarties_american"
[84] "smarties_commonwealth"
[85] "snickers"
[86] "sourpatch_kids_i_e_abominations_of_nature"
[87] "spotted_dick"
[88] "starburst"
[89] "sweet_tarts"
[90] "swedish_fish"
[91] "sweetums_a_friend_to_diabetes"
[92] "tic_tacs"
[93] "those_odd_marshmallow_circus_peanut_things"
[94] "three_musketeers"
[95] "tolberone_something_or_other"
[96] "trail_mix"
[97] "twix"
[98] "vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[99] "vicodin"
[100] "whatchamacallit_bars"
[101] "white_bread"
[102] "whole_wheat_anything"
[103] "york_peppermint_patties"
candy_2_tidy <- candy_2_less_columns %>%
rename("going_out" = starts_with("are_you_going_actually")) %>%
## add year column
add_column("year" = 2016) %>%
## rename common columns
rename("age" = "how_old_are_you") %>%
rename("country" = 4) %>%
rename("100_grand_bar" = 5)
candy_2_tidy
NA
#check column names/ numbers before pivot
names(candy_2_tidy)
[1] "going_out"
[2] "your_gender"
[3] "age"
[4] "country"
[5] "100_grand_bar"
[6] "anonymous_brown_globs_that_come_in_black_and_orange_wrappers"
[7] "any_full_sized_candy_bar"
[8] "black_jacks"
[9] "bonkers_the_candy"
[10] "bonkers_the_board_game"
[11] "bottle_caps"
[12] "boxo_raisins"
[13] "broken_glow_stick"
[14] "butterfinger"
[15] "cadbury_creme_eggs"
[16] "candy_corn"
[17] "candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[18] "caramellos"
[19] "cash_or_other_forms_of_legal_tender"
[20] "chardonnay"
[21] "chick_o_sticks_we_don_t_know_what_that_is"
[22] "chiclets"
[23] "coffee_crisp"
[24] "creepy_religious_comics_chick_tracts"
[25] "dental_paraphenalia"
[26] "dots"
[27] "dove_bars"
[28] "fuzzy_peaches"
[29] "generic_brand_acetaminophen"
[30] "glow_sticks"
[31] "goo_goo_clusters"
[32] "good_n_plenty"
[33] "gum_from_baseball_cards"
[34] "gummy_bears_straight_up"
[35] "hard_candy"
[36] "healthy_fruit"
[37] "heath_bar"
[38] "hersheys_dark_chocolate"
[39] "hershey_s_milk_chocolate"
[40] "hersheys_kisses"
[41] "hugs_actual_physical_hugs"
[42] "jolly_rancher_bad_flavor"
[43] "jolly_ranchers_good_flavor"
[44] "joy_joy_mit_iodine"
[45] "junior_mints"
[46] "senior_mints"
[47] "kale_smoothie"
[48] "kinder_happy_hippo"
[49] "kit_kat"
[50] "laffy_taffy"
[51] "lemon_heads"
[52] "licorice_not_black"
[53] "licorice_yes_black"
[54] "lindt_truffle"
[55] "lollipops"
[56] "mars"
[57] "mary_janes"
[58] "maynards"
[59] "mike_and_ike"
[60] "milk_duds"
[61] "milky_way"
[62] "regular_m_ms"
[63] "peanut_m_m_s"
[64] "blue_m_ms"
[65] "red_m_ms"
[66] "third_party_m_ms"
[67] "minibags_of_chips"
[68] "mint_kisses"
[69] "mint_juleps"
[70] "mr_goodbar"
[71] "necco_wafers"
[72] "nerds"
[73] "nestle_crunch"
[74] "nown_laters"
[75] "peeps"
[76] "pencils"
[77] "pixy_stix"
[78] "reese_s_peanut_butter_cups"
[79] "reeses_pieces"
[80] "reggie_jackson_bar"
[81] "rolos"
[82] "skittles"
[83] "smarties_american"
[84] "smarties_commonwealth"
[85] "snickers"
[86] "sourpatch_kids_i_e_abominations_of_nature"
[87] "spotted_dick"
[88] "starburst"
[89] "sweet_tarts"
[90] "swedish_fish"
[91] "sweetums_a_friend_to_diabetes"
[92] "tic_tacs"
[93] "those_odd_marshmallow_circus_peanut_things"
[94] "three_musketeers"
[95] "tolberone_something_or_other"
[96] "trail_mix"
[97] "twix"
[98] "vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[99] "vicodin"
[100] "whatchamacallit_bars"
[101] "white_bread"
[102] "whole_wheat_anything"
[103] "york_peppermint_patties"
[104] "year"
## pivot
candy_2_long <- candy_2_tidy %>%
pivot_longer(cols = 5:103, names_to = "candy_type", values_to = "response")
candy_2_long
##CANDY_3##
##check names
names(candy_3)
[1] "Internal ID"
[2] "Q1: GOING OUT?"
[3] "Q2: GENDER"
[4] "Q3: AGE"
[5] "Q4: COUNTRY"
[6] "Q5: STATE, PROVINCE, COUNTY, ETC"
[7] "Q6 | 100 Grand Bar"
[8] "Q6 | Anonymous brown globs that come in black and orange wrappers\t(a.k.a. Mary Janes)"
[9] "Q6 | Any full-sized candy bar"
[10] "Q6 | Black Jacks"
[11] "Q6 | Bonkers (the candy)"
[12] "Q6 | Bonkers (the board game)"
[13] "Q6 | Bottle Caps"
[14] "Q6 | Box'o'Raisins"
[15] "Q6 | Broken glow stick"
[16] "Q6 | Butterfinger"
[17] "Q6 | Cadbury Creme Eggs"
[18] "Q6 | Candy Corn"
[19] "Q6 | Candy that is clearly just the stuff given out for free at restaurants"
[20] "Q6 | Caramellos"
[21] "Q6 | Cash, or other forms of legal tender"
[22] "Q6 | Chardonnay"
[23] "Q6 | Chick-o-Sticks (we don’t know what that is)"
[24] "Q6 | Chiclets"
[25] "Q6 | Coffee Crisp"
[26] "Q6 | Creepy Religious comics/Chick Tracts"
[27] "Q6 | Dental paraphenalia"
[28] "Q6 | Dots"
[29] "Q6 | Dove Bars"
[30] "Q6 | Fuzzy Peaches"
[31] "Q6 | Generic Brand Acetaminophen"
[32] "Q6 | Glow sticks"
[33] "Q6 | Goo Goo Clusters"
[34] "Q6 | Good N' Plenty"
[35] "Q6 | Gum from baseball cards"
[36] "Q6 | Gummy Bears straight up"
[37] "Q6 | Hard Candy"
[38] "Q6 | Healthy Fruit"
[39] "Q6 | Heath Bar"
[40] "Q6 | Hershey's Dark Chocolate"
[41] "Q6 | Hershey’s Milk Chocolate"
[42] "Q6 | Hershey's Kisses"
[43] "Q6 | Hugs (actual physical hugs)"
[44] "Q6 | Jolly Rancher (bad flavor)"
[45] "Q6 | Jolly Ranchers (good flavor)"
[46] "Q6 | JoyJoy (Mit Iodine!)"
[47] "Q6 | Junior Mints"
[48] "Q6 | Senior Mints"
[49] "Q6 | Kale smoothie"
[50] "Q6 | Kinder Happy Hippo"
[51] "Q6 | Kit Kat"
[52] "Q6 | LaffyTaffy"
[53] "Q6 | LemonHeads"
[54] "Q6 | Licorice (not black)"
[55] "Q6 | Licorice (yes black)"
[56] "Q6 | Lindt Truffle"
[57] "Q6 | Lollipops"
[58] "Q6 | Mars"
[59] "Q6 | Maynards"
[60] "Q6 | Mike and Ike"
[61] "Q6 | Milk Duds"
[62] "Q6 | Milky Way"
[63] "Q6 | Regular M&Ms"
[64] "Q6 | Peanut M&M’s"
[65] "Q6 | Blue M&M's"
[66] "Q6 | Red M&M's"
[67] "Q6 | Green Party M&M's"
[68] "Q6 | Independent M&M's"
[69] "Q6 | Abstained from M&M'ing."
[70] "Q6 | Minibags of chips"
[71] "Q6 | Mint Kisses"
[72] "Q6 | Mint Juleps"
[73] "Q6 | Mr. Goodbar"
[74] "Q6 | Necco Wafers"
[75] "Q6 | Nerds"
[76] "Q6 | Nestle Crunch"
[77] "Q6 | Now'n'Laters"
[78] "Q6 | Peeps"
[79] "Q6 | Pencils"
[80] "Q6 | Pixy Stix"
[81] "Q6 | Real Housewives of Orange County Season 9 Blue-Ray"
[82] "Q6 | Reese’s Peanut Butter Cups"
[83] "Q6 | Reese's Pieces"
[84] "Q6 | Reggie Jackson Bar"
[85] "Q6 | Rolos"
[86] "Q6 | Sandwich-sized bags filled with BooBerry Crunch"
[87] "Q6 | Skittles"
[88] "Q6 | Smarties (American)"
[89] "Q6 | Smarties (Commonwealth)"
[90] "Q6 | Snickers"
[91] "Q6 | Sourpatch Kids (i.e. abominations of nature)"
[92] "Q6 | Spotted Dick"
[93] "Q6 | Starburst"
[94] "Q6 | Sweet Tarts"
[95] "Q6 | Swedish Fish"
[96] "Q6 | Sweetums (a friend to diabetes)"
[97] "Q6 | Take 5"
[98] "Q6 | Tic Tacs"
[99] "Q6 | Those odd marshmallow circus peanut things"
[100] "Q6 | Three Musketeers"
[101] "Q6 | Tolberone something or other"
[102] "Q6 | Trail Mix"
[103] "Q6 | Twix"
[104] "Q6 | Vials of pure high fructose corn syrup, for main-lining into your vein"
[105] "Q6 | Vicodin"
[106] "Q6 | Whatchamacallit Bars"
[107] "Q6 | White Bread"
[108] "Q6 | Whole Wheat anything"
[109] "Q6 | York Peppermint Patties"
[110] "Q7: JOY OTHER"
[111] "Q8: DESPAIR OTHER"
[112] "Q9: OTHER COMMENTS"
[113] "Q10: DRESS"
[114] "...114"
[115] "Q11: DAY"
[116] "Q12: MEDIA [Daily Dish]"
[117] "Q12: MEDIA [Science]"
[118] "Q12: MEDIA [ESPN]"
[119] "Q12: MEDIA [Yahoo]"
[120] "Click Coordinates (x, y)"
candy_3_clean_names <- clean_names(candy_3)
candy_3_clean_names
names(candy_3_clean_names)
[1] "internal_id"
[2] "q1_going_out"
[3] "q2_gender"
[4] "q3_age"
[5] "q4_country"
[6] "q5_state_province_county_etc"
[7] "q6_100_grand_bar"
[8] "q6_anonymous_brown_globs_that_come_in_black_and_orange_wrappers_a_k_a_mary_janes"
[9] "q6_any_full_sized_candy_bar"
[10] "q6_black_jacks"
[11] "q6_bonkers_the_candy"
[12] "q6_bonkers_the_board_game"
[13] "q6_bottle_caps"
[14] "q6_boxo_raisins"
[15] "q6_broken_glow_stick"
[16] "q6_butterfinger"
[17] "q6_cadbury_creme_eggs"
[18] "q6_candy_corn"
[19] "q6_candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[20] "q6_caramellos"
[21] "q6_cash_or_other_forms_of_legal_tender"
[22] "q6_chardonnay"
[23] "q6_chick_o_sticks_we_don_t_know_what_that_is"
[24] "q6_chiclets"
[25] "q6_coffee_crisp"
[26] "q6_creepy_religious_comics_chick_tracts"
[27] "q6_dental_paraphenalia"
[28] "q6_dots"
[29] "q6_dove_bars"
[30] "q6_fuzzy_peaches"
[31] "q6_generic_brand_acetaminophen"
[32] "q6_glow_sticks"
[33] "q6_goo_goo_clusters"
[34] "q6_good_n_plenty"
[35] "q6_gum_from_baseball_cards"
[36] "q6_gummy_bears_straight_up"
[37] "q6_hard_candy"
[38] "q6_healthy_fruit"
[39] "q6_heath_bar"
[40] "q6_hersheys_dark_chocolate"
[41] "q6_hershey_s_milk_chocolate"
[42] "q6_hersheys_kisses"
[43] "q6_hugs_actual_physical_hugs"
[44] "q6_jolly_rancher_bad_flavor"
[45] "q6_jolly_ranchers_good_flavor"
[46] "q6_joy_joy_mit_iodine"
[47] "q6_junior_mints"
[48] "q6_senior_mints"
[49] "q6_kale_smoothie"
[50] "q6_kinder_happy_hippo"
[51] "q6_kit_kat"
[52] "q6_laffy_taffy"
[53] "q6_lemon_heads"
[54] "q6_licorice_not_black"
[55] "q6_licorice_yes_black"
[56] "q6_lindt_truffle"
[57] "q6_lollipops"
[58] "q6_mars"
[59] "q6_maynards"
[60] "q6_mike_and_ike"
[61] "q6_milk_duds"
[62] "q6_milky_way"
[63] "q6_regular_m_ms"
[64] "q6_peanut_m_m_s"
[65] "q6_blue_m_ms"
[66] "q6_red_m_ms"
[67] "q6_green_party_m_ms"
[68] "q6_independent_m_ms"
[69] "q6_abstained_from_m_ming"
[70] "q6_minibags_of_chips"
[71] "q6_mint_kisses"
[72] "q6_mint_juleps"
[73] "q6_mr_goodbar"
[74] "q6_necco_wafers"
[75] "q6_nerds"
[76] "q6_nestle_crunch"
[77] "q6_nown_laters"
[78] "q6_peeps"
[79] "q6_pencils"
[80] "q6_pixy_stix"
[81] "q6_real_housewives_of_orange_county_season_9_blue_ray"
[82] "q6_reese_s_peanut_butter_cups"
[83] "q6_reeses_pieces"
[84] "q6_reggie_jackson_bar"
[85] "q6_rolos"
[86] "q6_sandwich_sized_bags_filled_with_boo_berry_crunch"
[87] "q6_skittles"
[88] "q6_smarties_american"
[89] "q6_smarties_commonwealth"
[90] "q6_snickers"
[91] "q6_sourpatch_kids_i_e_abominations_of_nature"
[92] "q6_spotted_dick"
[93] "q6_starburst"
[94] "q6_sweet_tarts"
[95] "q6_swedish_fish"
[96] "q6_sweetums_a_friend_to_diabetes"
[97] "q6_take_5"
[98] "q6_tic_tacs"
[99] "q6_those_odd_marshmallow_circus_peanut_things"
[100] "q6_three_musketeers"
[101] "q6_tolberone_something_or_other"
[102] "q6_trail_mix"
[103] "q6_twix"
[104] "q6_vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[105] "q6_vicodin"
[106] "q6_whatchamacallit_bars"
[107] "q6_white_bread"
[108] "q6_whole_wheat_anything"
[109] "q6_york_peppermint_patties"
[110] "q7_joy_other"
[111] "q8_despair_other"
[112] "q9_other_comments"
[113] "q10_dress"
[114] "x114"
[115] "q11_day"
[116] "q12_media_daily_dish"
[117] "q12_media_science"
[118] "q12_media_espn"
[119] "q12_media_yahoo"
[120] "click_coordinates_x_y"
candy_3_less <- candy_3_clean_names %>%
select(-1, -6, -c(110:120))
names(candy_3_less)
[1] "q1_going_out"
[2] "q2_gender"
[3] "q3_age"
[4] "q4_country"
[5] "q6_100_grand_bar"
[6] "q6_anonymous_brown_globs_that_come_in_black_and_orange_wrappers_a_k_a_mary_janes"
[7] "q6_any_full_sized_candy_bar"
[8] "q6_black_jacks"
[9] "q6_bonkers_the_candy"
[10] "q6_bonkers_the_board_game"
[11] "q6_bottle_caps"
[12] "q6_boxo_raisins"
[13] "q6_broken_glow_stick"
[14] "q6_butterfinger"
[15] "q6_cadbury_creme_eggs"
[16] "q6_candy_corn"
[17] "q6_candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[18] "q6_caramellos"
[19] "q6_cash_or_other_forms_of_legal_tender"
[20] "q6_chardonnay"
[21] "q6_chick_o_sticks_we_don_t_know_what_that_is"
[22] "q6_chiclets"
[23] "q6_coffee_crisp"
[24] "q6_creepy_religious_comics_chick_tracts"
[25] "q6_dental_paraphenalia"
[26] "q6_dots"
[27] "q6_dove_bars"
[28] "q6_fuzzy_peaches"
[29] "q6_generic_brand_acetaminophen"
[30] "q6_glow_sticks"
[31] "q6_goo_goo_clusters"
[32] "q6_good_n_plenty"
[33] "q6_gum_from_baseball_cards"
[34] "q6_gummy_bears_straight_up"
[35] "q6_hard_candy"
[36] "q6_healthy_fruit"
[37] "q6_heath_bar"
[38] "q6_hersheys_dark_chocolate"
[39] "q6_hershey_s_milk_chocolate"
[40] "q6_hersheys_kisses"
[41] "q6_hugs_actual_physical_hugs"
[42] "q6_jolly_rancher_bad_flavor"
[43] "q6_jolly_ranchers_good_flavor"
[44] "q6_joy_joy_mit_iodine"
[45] "q6_junior_mints"
[46] "q6_senior_mints"
[47] "q6_kale_smoothie"
[48] "q6_kinder_happy_hippo"
[49] "q6_kit_kat"
[50] "q6_laffy_taffy"
[51] "q6_lemon_heads"
[52] "q6_licorice_not_black"
[53] "q6_licorice_yes_black"
[54] "q6_lindt_truffle"
[55] "q6_lollipops"
[56] "q6_mars"
[57] "q6_maynards"
[58] "q6_mike_and_ike"
[59] "q6_milk_duds"
[60] "q6_milky_way"
[61] "q6_regular_m_ms"
[62] "q6_peanut_m_m_s"
[63] "q6_blue_m_ms"
[64] "q6_red_m_ms"
[65] "q6_green_party_m_ms"
[66] "q6_independent_m_ms"
[67] "q6_abstained_from_m_ming"
[68] "q6_minibags_of_chips"
[69] "q6_mint_kisses"
[70] "q6_mint_juleps"
[71] "q6_mr_goodbar"
[72] "q6_necco_wafers"
[73] "q6_nerds"
[74] "q6_nestle_crunch"
[75] "q6_nown_laters"
[76] "q6_peeps"
[77] "q6_pencils"
[78] "q6_pixy_stix"
[79] "q6_real_housewives_of_orange_county_season_9_blue_ray"
[80] "q6_reese_s_peanut_butter_cups"
[81] "q6_reeses_pieces"
[82] "q6_reggie_jackson_bar"
[83] "q6_rolos"
[84] "q6_sandwich_sized_bags_filled_with_boo_berry_crunch"
[85] "q6_skittles"
[86] "q6_smarties_american"
[87] "q6_smarties_commonwealth"
[88] "q6_snickers"
[89] "q6_sourpatch_kids_i_e_abominations_of_nature"
[90] "q6_spotted_dick"
[91] "q6_starburst"
[92] "q6_sweet_tarts"
[93] "q6_swedish_fish"
[94] "q6_sweetums_a_friend_to_diabetes"
[95] "q6_take_5"
[96] "q6_tic_tacs"
[97] "q6_those_odd_marshmallow_circus_peanut_things"
[98] "q6_three_musketeers"
[99] "q6_tolberone_something_or_other"
[100] "q6_trail_mix"
[101] "q6_twix"
[102] "q6_vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[103] "q6_vicodin"
[104] "q6_whatchamacallit_bars"
[105] "q6_white_bread"
[106] "q6_whole_wheat_anything"
[107] "q6_york_peppermint_patties"
candy_3_tidy <- candy_3_less %>%
#rename to match format
rename("going_out" = 1) %>%
rename("your_gender" = 2) %>%
rename("age" = 3) %>%
rename("country" = 4) %>%
##add "year" = 2017 column
add_column("year" = 2017)
names(candy_3_tidy)
[1] "going_out"
[2] "your_gender"
[3] "age"
[4] "country"
[5] "q6_100_grand_bar"
[6] "q6_anonymous_brown_globs_that_come_in_black_and_orange_wrappers_a_k_a_mary_janes"
[7] "q6_any_full_sized_candy_bar"
[8] "q6_black_jacks"
[9] "q6_bonkers_the_candy"
[10] "q6_bonkers_the_board_game"
[11] "q6_bottle_caps"
[12] "q6_boxo_raisins"
[13] "q6_broken_glow_stick"
[14] "q6_butterfinger"
[15] "q6_cadbury_creme_eggs"
[16] "q6_candy_corn"
[17] "q6_candy_that_is_clearly_just_the_stuff_given_out_for_free_at_restaurants"
[18] "q6_caramellos"
[19] "q6_cash_or_other_forms_of_legal_tender"
[20] "q6_chardonnay"
[21] "q6_chick_o_sticks_we_don_t_know_what_that_is"
[22] "q6_chiclets"
[23] "q6_coffee_crisp"
[24] "q6_creepy_religious_comics_chick_tracts"
[25] "q6_dental_paraphenalia"
[26] "q6_dots"
[27] "q6_dove_bars"
[28] "q6_fuzzy_peaches"
[29] "q6_generic_brand_acetaminophen"
[30] "q6_glow_sticks"
[31] "q6_goo_goo_clusters"
[32] "q6_good_n_plenty"
[33] "q6_gum_from_baseball_cards"
[34] "q6_gummy_bears_straight_up"
[35] "q6_hard_candy"
[36] "q6_healthy_fruit"
[37] "q6_heath_bar"
[38] "q6_hersheys_dark_chocolate"
[39] "q6_hershey_s_milk_chocolate"
[40] "q6_hersheys_kisses"
[41] "q6_hugs_actual_physical_hugs"
[42] "q6_jolly_rancher_bad_flavor"
[43] "q6_jolly_ranchers_good_flavor"
[44] "q6_joy_joy_mit_iodine"
[45] "q6_junior_mints"
[46] "q6_senior_mints"
[47] "q6_kale_smoothie"
[48] "q6_kinder_happy_hippo"
[49] "q6_kit_kat"
[50] "q6_laffy_taffy"
[51] "q6_lemon_heads"
[52] "q6_licorice_not_black"
[53] "q6_licorice_yes_black"
[54] "q6_lindt_truffle"
[55] "q6_lollipops"
[56] "q6_mars"
[57] "q6_maynards"
[58] "q6_mike_and_ike"
[59] "q6_milk_duds"
[60] "q6_milky_way"
[61] "q6_regular_m_ms"
[62] "q6_peanut_m_m_s"
[63] "q6_blue_m_ms"
[64] "q6_red_m_ms"
[65] "q6_green_party_m_ms"
[66] "q6_independent_m_ms"
[67] "q6_abstained_from_m_ming"
[68] "q6_minibags_of_chips"
[69] "q6_mint_kisses"
[70] "q6_mint_juleps"
[71] "q6_mr_goodbar"
[72] "q6_necco_wafers"
[73] "q6_nerds"
[74] "q6_nestle_crunch"
[75] "q6_nown_laters"
[76] "q6_peeps"
[77] "q6_pencils"
[78] "q6_pixy_stix"
[79] "q6_real_housewives_of_orange_county_season_9_blue_ray"
[80] "q6_reese_s_peanut_butter_cups"
[81] "q6_reeses_pieces"
[82] "q6_reggie_jackson_bar"
[83] "q6_rolos"
[84] "q6_sandwich_sized_bags_filled_with_boo_berry_crunch"
[85] "q6_skittles"
[86] "q6_smarties_american"
[87] "q6_smarties_commonwealth"
[88] "q6_snickers"
[89] "q6_sourpatch_kids_i_e_abominations_of_nature"
[90] "q6_spotted_dick"
[91] "q6_starburst"
[92] "q6_sweet_tarts"
[93] "q6_swedish_fish"
[94] "q6_sweetums_a_friend_to_diabetes"
[95] "q6_take_5"
[96] "q6_tic_tacs"
[97] "q6_those_odd_marshmallow_circus_peanut_things"
[98] "q6_three_musketeers"
[99] "q6_tolberone_something_or_other"
[100] "q6_trail_mix"
[101] "q6_twix"
[102] "q6_vials_of_pure_high_fructose_corn_syrup_for_main_lining_into_your_vein"
[103] "q6_vicodin"
[104] "q6_whatchamacallit_bars"
[105] "q6_white_bread"
[106] "q6_whole_wheat_anything"
[107] "q6_york_peppermint_patties"
[108] "year"
candy_3_long <- candy_3_tidy %>%
pivot_longer(cols = 5:107, names_to = "candy_type", values_to = "response")
candy_3_long
## test to split the q6_candy_type column
## why is th "test" column showing just the first word?
candy_3_long_q_sep <- candy_3_long %>%
separate(candy_type, c("question", "test"), sep = "_")
Expected 2 pieces. Additional pieces discarded in 211560 rows [1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 15, 17, 19, 20, 21, 23, 24, 25, ...].
head(candy_3_long_q_sep)
view(candy_3_long_q_sep)
##CANDY_JOINED##
candy_joined <- bind_rows(candy_1_long, candy_2_long, candy_3_long)
view(candy_joined)
candy_type_fixed <- candy_joined$candy_type %>% str_replace_all("q6_","")
view(candy_type_fixed)